package com.rms.server.Dao;


import com.rms.server.Domain.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserDao {
    @Select("SELECT * FROM user WHERE uid = #{uid} and upassword = #{upassword}")
    User findByUidAddUpassword(@Param("uid") Long id, @Param("upassword") String password);

    @Select("SELECT * FROM user WHERE uid = #{uid}")
    User findByUid(@Param("uid") Long id);

    @Insert("INSERT INTO USER (uid, upassword, urole, uname, uavatar) SELECT IF(max(uid) IS NULL, 1, max(uid) + 1) AS topID,#{upassword},#{urole},#{uname},#{uavatar} FROM USER;")
    void insertUser(@Param("upassword") String password,
                    @Param("uname") String name,
                    @Param("urole") String role,
                    @Param("uavatar") String avatar
    );
}
